<%@page import="common.CodeChenge"%>
<%@page import="java.util.ArrayList"%>
<%@page import="test.login.User"%>
<%@page import="java.util.List"%>
<%@page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; UTF-8">
<title>USER LIST</title>
<script type="text/javascript">
<!--

function regist(str,no){

	if (str == 1){
		document.s_Button.action= "/WebSample2nd/userlist";
		document.s_Button.submit();
	}
	if (str == 2){
		document.s_Button.inputFlg.value = "0";
		document.s_Button.targetId.value = "";
		document.s_Button.action= "/WebSample2nd/userinput";
		document.s_Button.submit();
	}
	if (str == 3){
		document.s_Button.inputFlg.value = "1";
		document.s_Button.targetId.value = no;
		document.s_Button.action= "/WebSample2nd/userinput";
		document.s_Button.submit();
	}

}

// -->
</script>
</head>
<body>
<h1>USER LIST</h1>
<%-- 検索部分 --%>
<form method="POST" name="s_Button" action="">
<input type="hidden" name="inputFlg" value="">
<input type="hidden"  name="targetId" value="">
<input type="hidden" name="s_password" value="">
<input type="hidden" name="s_passwordr" value="">

ログインＩＤ：<input size=50 type="text"  name="s_id"></input>
<br></br>
ユーザ名：<input size=50 type="text"  name="s_user"></input>
<br></br>
管理者権限
<input type="radio" name="s_adminflg" value="all" checked>全て
<input type="radio" name="s_adminflg" value="1">あり
<input type="radio" name="s_adminflg" value="0">なし
<br></br>
<input type="button" name="s_Search" value="検索" onclick="regist(1,0)">
<input type="button" name="s_Regist" value="登録" onclick="regist(2,0)">
<br></br>

<%-- ループ処理でユーザ一覧を表示 --%>
<table border=4 width=80% align=center>
<tr>
<th align="left">ログインID</th>
<th align="left">ユーザ名</th>
<th align="left">管理者権限</th>
<th align="right"></th>
</tr>
<%
 List<User> userList = (List<User>)request.getAttribute("userList");
 int i = 0;
 User user = null;
 for ( i = 0 ; i < userList.size(); i++) {
	user = (User) userList.get(i);
 %>
	<tr>
	<th align="left"><%= CodeChenge.HtmlChenge(user.getLoginId()) %></th>
	<th align="left"><%= CodeChenge.HtmlChenge(user.getName()) %></th>
	<%
	if(user.getAdminFlg() == '1') {
	%>
		<th align="left">あり</th>
	<%
	} else {
	%>
		<th align="left">なし</th>
	<%
	}
	%>
	<th align="right"><input type="button" value="変更" onclick="regist(3,<%= user.getUserId() %>)"></th>
	</tr>
<%
}
%>
</table>
</form>
</body>
</html>